﻿package mortal.game.view.friend
{
    import com.mui.controls.*;
    import extend.language.*;
    import fl.data.*;
    import flash.display.*;
    import flash.events.*;
    import mortal.common.global.*;
    import mortal.component.window.*;
    import mortal.game.cache.*;
    import mortal.game.mvc.*;
    import mortal.game.view.common.*;
    import mortal.game.view.friend.data.*;
    import mortal.game.view.friend.renderer.*;
    import mortal.mvc.core.*;

    public class FriendRecommendWin extends BaseWindow
    {
        private var _recommendList:GTileList;
        private var _allAddBtn:GButton;
        private static var _instance:FriendRecommendWin;

        public function FriendRecommendWin(param1:ExceptionClass)
        {
            this.init();
            return;
        }// end function

        private function init() : void
        {
            title = Language.getString(41237);
            setSize(434, 503);
            return;
        }// end function

        override protected function createDisposedChildrenImpl() : void
        {
            super.createDisposedChildrenImpl();
            this.pushUIToDisposeVec(UIFactory.bg(10, 32, 95, 23, this));
            this.pushUIToDisposeVec(UIFactory.bg(106, 32, 76, 23, this));
            this.pushUIToDisposeVec(UIFactory.bg(182, 32, 77, 23, this));
            this.pushUIToDisposeVec(UIFactory.bg(261, 32, 86, 23, this));
            this.pushUIToDisposeVec(UIFactory.bg(348, 32, 78, 23, this));
            this.pushUIToDisposeVec(UIFactory.gTextField(Language.getString(41238), 30, 33, 60, 20, this, GlobalStyle.textFormatHuang));
            this.pushUIToDisposeVec(UIFactory.gTextField(Language.getString(41239), 128, 33, 60, 20, this, GlobalStyle.textFormatHuang));
            this.pushUIToDisposeVec(UIFactory.gTextField(Language.getString(41240), 204, 33, 60, 20, this, GlobalStyle.textFormatHuang));
            this.pushUIToDisposeVec(UIFactory.gTextField(Language.getString(41241), 282, 33, 60, 20, this, GlobalStyle.textFormatHuang));
            this.pushUIToDisposeVec(UIFactory.gTextField(Language.getString(41242), 370, 33, 60, 20, this, GlobalStyle.textFormatHuang));
            this._recommendList = UIFactory.tileList(10, 63, 415, 401, this);
            this._recommendList.columnWidth = 415;
            this._recommendList.rowHeight = 40;
            this._recommendList.horizontalGap = 0;
            this._recommendList.verticalGap = 0;
            this._recommendList.setStyle("skin", new Bitmap());
            this._recommendList.setStyle("cellRenderer", FriendRecommendRenderer);
            this._allAddBtn = UIFactory.gButton(Language.getString(41243), 164, 461, 90, 37, this);
            this._allAddBtn.configEventListener(MouseEvent.CLICK, this.onClickHandler);
            this.initRecommendList();
            this.addListeners();
            return;
        }// end function

        private function initRecommendList() : void
        {
            this.updateRecommendList();
            return;
        }// end function

        private function addListeners() : void
        {
            NetDispatcher.addCmdListener(ServerCommand.FriendApplySucc, this.onApplySuccHandler);
            return;
        }// end function

        private function removeListeners() : void
        {
            NetDispatcher.removeCmdListener(ServerCommand.FriendApplySucc, this.onApplySuccHandler);
            return;
        }// end function

        private function onClickHandler(event:MouseEvent) : void
        {
            var _loc_4:RoleInfoData = null;
            var _loc_2:* = Cache.instance.friend.recommendList;
            var _loc_3:Array = [];
            for each (_loc_4 in _loc_2)
            {
                
                _loc_3.push(_loc_4.roleName);
            }
            GameProxy.friend.apply(_loc_3);
            this.hide();
            return;
        }// end function

        private function onApplySuccHandler(param1:Object) : void
        {
            var _loc_2:* = param1 as Array;
            Cache.instance.friend.updateRecommendList(_loc_2);
            var _loc_3:* = Cache.instance.friend.recommendList;
            if (!isHide)
            {
                this.updateRecommendList();
            }
            return;
        }// end function

        private function updateRecommendList() : void
        {
            var _loc_1:* = Cache.instance.friend.recommendList;
            var _loc_2:* = new DataProvider();
            _loc_2.addItems(_loc_1);
            this._recommendList.dataProvider = _loc_2;
            this._recommendList.drawNow();
            return;
        }// end function

        override protected function disposeImpl(param1:Boolean = true) : void
        {
            super.disposeImpl(param1);
            this._recommendList.dispose(param1);
            this._allAddBtn.dispose(param1);
            this._recommendList = null;
            this._allAddBtn = null;
            this.removeListeners();
            return;
        }// end function

        public static function get instance() : FriendRecommendWin
        {
            if (!_instance)
            {
                _instance = new FriendRecommendWin(new ExceptionClass());
            }
            return _instance;
        }// end function

    }
}

class ExceptionClass extends Object
{

    function ExceptionClass()
    {
        return;
    }// end function

}

